package com.hljx.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hljx.config.Result;
import com.hljx.dto.DateDTO;
import com.hljx.entity.EtlItemSummary;
import com.hljx.entity.WorkloadSummary;
import com.hljx.service.WorkloadSummaryService;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2023-11-29
 */
@RestController
@RequestMapping("/workloadSummary")
public class WorkloadSummaryController {

    @Autowired
    private WorkloadSummaryService  workloadSummaryService;

    @Operation(summary = "工作量指标分值")
    @PostMapping("/listByPeriod")
    public Result<List<WorkloadSummary>> listByPeriod(@RequestBody DateDTO dateDTO) {

        List<WorkloadSummary> workloadSummaries = workloadSummaryService.listByPage(dateDTO);
        return Result.success(workloadSummaries);
    }


    @Operation(summary = "导出")
    @PostMapping("/export")
    public void export(@RequestBody DateDTO dateDTO, HttpServletResponse response) throws ClassNotFoundException {
        workloadSummaryService.export(dateDTO,response);

    }
}
